package cn.nubia.admin.sysconfig.bean;

import cn.nubia.admin.application.bean.ServiceConstant;
import cn.nubia.admin.common.mybatis.annotations.Column;
import cn.nubia.admin.common.mybatis.annotations.Id;
import cn.nubia.admin.common.mybatis.annotations.Table;
import cn.nubia.admin.common.mybatis.annotations.UnColumn;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by justin on 15/8/19.
 *
 * CREATE TABLE `nb_soft_operate_log` (
 `log_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '日志编号',
 `operate_type` smallint(6) DEFAULT NULL COMMENT '操作类型 (0: 修改 1:审核)',
 `module_type` smallint(6) DEFAULT NULL COMMENT '操作模块（0： 软件表  1 软件版
 本表  2 项目软件表）',
 `resouce_object` longtext COMMENT '原始数据',
 `new_object` longtext COMMENT '处理后数据',
 `object_id` int(11) DEFAULT NULL COMMENT '处理对象编号',
 `create_time` int(11) DEFAULT NULL COMMENT '创建时间',
 `create_name` varchar(20) DEFAULT NULL COMMENT '创建人姓名',
 `create_id` int(11) DEFAULT NULL COMMENT '创建人编号',
 PRIMARY KEY (`log_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='软件操作信息记录';
 */
@Table(value = "nb_operate_log" ,splitYear=true )
public class SystemLog implements Serializable {

    public static List<ServiceConstant.Option> modules = null;

    public static final String COLUMN_MODULETYPE = "moduleType";

    public static final String COLUMN_CREATENAME = "createName";

    public static final String COLUMN_CREATETIME = "createTime";

    @Id(value = "log_id")
    private Integer id;

    private Integer operateType;

    private Integer moduleType;

    private Integer objectId;

    private Integer createTime;

    private String createName;

    private Integer createId;


    @UnColumn
    private String operateTypeName;
    @UnColumn
    private String moduleTypeName;
    @UnColumn
    private String createTimeShow;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getOperateType() {
        return operateType;
    }

    public void setOperateType(Integer operateType) {
        this.operateType = operateType;
    }

    public Integer getModuleType() {
        return moduleType;
    }

    public void setModuleType(Integer moduleType) {
        this.moduleType = moduleType;
    }

    public Integer getObjectId() {
        return objectId;
    }

    public void setObjectId(Integer objectId) {
        this.objectId = objectId;
    }

    public Integer getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Integer createTime) {
        this.createTime = createTime;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public Integer getCreateId() {
        return createId;
    }

    public void setCreateId(Integer createId) {
        this.createId = createId;
    }

    public String getOperateTypeName() {
        return operateTypeName;
    }

    public void setOperateTypeName(String operateTypeName) {
        this.operateTypeName = operateTypeName;
    }

    public String getModuleTypeName() {
        return moduleTypeName;
    }

    public void setModuleTypeName(String moduleTypeName) {
        this.moduleTypeName = moduleTypeName;
    }

    public String getCreateTimeShow() {
        return createTimeShow;
    }

    public void setCreateTimeShow(String createTimeShow) {
        this.createTimeShow = createTimeShow;
    }

    public enum ModuleTypeEnum{


        LISTSOFT("listSoft",1,"应用管理模块"),
        LISTSOFTITEMS("listSoftItems",2,"应用版本管理模块"),
        ADITEMLIST("aditemlist",4,"广告管理模块"),
        CHANNELLIST("channellist",5,"渠道商管理模块"),
        CLAIMLIST("claimlist",6,"举报管理模块"),
        CLIENTLIST("clientlist",7,"客户端管理模块"),
        FEEDBACKLIST("feedbacklist",8,"建议管理模块"),
        NOTIFYPUSHLIST("notifypushlist",9,"消息推送管理模块"),
        SEARCHGENERALLIST("searchGenerallist",10,"搜索推广管理模块"),
        SOFTCOMMENTLIST("softrecommendlist",11,"评论管理模块"),
        SOFTEVALUATINGLIST("softevaluatinglist",12,"最美应用管理模块"),
        SOFTRECOMMENDLIST("softrecommendlist",13,"精品推荐管理模块"),
        TOPICLIST("topiclist",14,"专题管理模块"),
        TOPICMAPLIST("topicmaplist",15,"专题内容管理模块"),
        CATEGORYLIST("categorylist",16,"分类管理模块"),
        DICTFIELDLIST("dictfield",17,"枚举管理模块"),
        DICTFIELDITEMLIST("dictfielditem",18,"枚举字段管理模块"),
        MENURESOURCELIST("menuresource",19,"菜单权限管理模块"),
        ROLELIST("role",20,"角色管理模块"),
        MENULIST("menu",21,"菜单管理模块"),
        ROLERESOURCELIST("roleresource",22,"角色权限管理模块"),
        ROLEUSERLIST("roleuser",23,"用户角色管理模块"),
        USERRESOURCELIST("userresource",24,"用户权限管理模块"),
        USERLIST("user",25,"用户管理模块"),
        SYSCONFIGLIST("sysconfig",26,"系统信息管理模块"),
        ADSPACELIST("adspacelist",3,"广告位管理模块"),
        SOFTRECRANK("softRecRank",27,"运营推荐管理模块"),
        TAGMAPLIST("tagmaplist",28,"标签内容管理模块"),
        TAGLIST("taglist",29,"标签管理模块");

//        SOFTRECMNG("softrecmng",2,"应用推荐"),
//        CLIENTMNG("clientmng",3,"客户端管理"),
//        ADMNG("admng",4,"广告管理");


        private ModuleTypeEnum(String key,Integer value,String tag){
            this.key = key;
            this.value = value;
            this.tag = tag;
        }

        public String key;

        public Integer value;

        public String tag;

        public static ModuleTypeEnum getByValue(Integer value){
            for(ModuleTypeEnum moduleTypeEnum : ModuleTypeEnum.values()){
                if(moduleTypeEnum.value.intValue() == value.intValue()){
                    return moduleTypeEnum;
                }
            }
            return null;
        }

        public static List<ServiceConstant.Option> getModules(){
            if(modules == null){
                modules = new ArrayList<>();
                for(ModuleTypeEnum moduleTypeEnum : ModuleTypeEnum.values()){
                    modules.add(new ServiceConstant.Option(String.valueOf(moduleTypeEnum.value),moduleTypeEnum.tag));
                }
            }
            return modules;
        }
    }

    public enum OperateTypeEnum{

        ADD("add",1,"添加"),
        EDIT("edit",2,"编辑"),
        DEL("del",3,"删除"),
        HIDDEN("hidden",4,"隐藏"),
        SHOW("show",5,"展示"),
        UP("up",6,"上架"),
        DOWN("down",7,"下架"),
        CHECK("check",8,"审核"),
        READED("readed",10,"已阅"),
        CHECKNO("checkno",9,"审核不通过"),
        REPLY("reply",10,"回复");

        private OperateTypeEnum(String key,Integer value,String tag){
            this.key = key;
            this.value = value;
            this.tag = tag;
        }

        public String key;

        public Integer value;

        public String tag;

        public static OperateTypeEnum getByValue(Integer value){
            for(OperateTypeEnum operateTypeEnum:OperateTypeEnum.values()){
                if(operateTypeEnum.value.intValue() == value.intValue()){
                    return operateTypeEnum;
                }
            }
            return null;
        }

    }
}
